home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / kidplay / playwav.frm < prev    next >
Text File  |  1995-05-08  |  4KB  |  141 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "PLAYWAV"
  4.    ClientHeight    =   4530
  5.    ClientLeft      =   1065
  6.    ClientTop       =   1350
  7.    ClientWidth     =   11670
  8.    FontBold        =   -1  'True
  9.    FontItalic      =   0   'False
  10.    FontName        =   "MS Sans Serif"
  11.    FontSize        =   29.25
  12.    FontStrikethru  =   0   'False
  13.    FontUnderline   =   0   'False
  14.    Height          =   4935
  15.    Left            =   1005
  16.    LinkMode        =   1  'Source
  17.    LinkTopic       =   "Form1"
  18.    ScaleHeight     =   4530
  19.    ScaleWidth      =   11670
  20.    Top             =   1005
  21.    Width           =   11790
  22.    Begin TextBox Name2 
  23.       FontBold        =   -1  'True
  24.       FontItalic      =   0   'False
  25.       FontName        =   "MS Sans Serif"
  26.       FontSize        =   29.25
  27.       FontStrikethru  =   0   'False
  28.       FontUnderline   =   0   'False
  29.       Height          =   840
  30.       Left            =   4080
  31.       TabIndex        =   2
  32.       Top             =   3720
  33.       Width           =   7575
  34.    End
  35.    Begin TextBox Name1 
  36.       FontBold        =   -1  'True
  37.       FontItalic      =   0   'False
  38.       FontName        =   "MS Sans Serif"
  39.       FontSize        =   29.25
  40.       FontStrikethru  =   0   'False
  41.       FontUnderline   =   0   'False
  42.       Height          =   840
  43.       Left            =   0
  44.       TabIndex        =   1
  45.       Top             =   3720
  46.       Width           =   4095
  47.    End
  48.    Begin PictureBox Picture1 
  49.       Height          =   615
  50.       Index           =   0
  51.       Left            =   0
  52.       ScaleHeight     =   585
  53.       ScaleWidth      =   585
  54.       TabIndex        =   0
  55.       Top             =   0
  56.       Width           =   615
  57.    End
  58. End
  59. Dim a$(114)
  60. Dim b$(500)
  61. Dim ActualIcons As Integer
  62.  
  63. Sub Form_Load ()
  64.     vsize = Picture1(0).Height
  65.     hsize = Picture1(0).Width
  66.     Picture1(0).BackColor = RGB(Rnd(1) * 256, Rnd(1) * 256, Rnd(1) * 256)
  67.     For i = 1 To 113
  68.     ih = Int(i / 19)
  69.     il = i - ih * 19
  70.     Load Picture1(i)
  71.     Picture1(i).Top = ih * vsize
  72.     Picture1(i).left = il * hsize
  73.     Picture1(i).BackColor = RGB(Rnd(1) * 256, Rnd(1) * 256, Rnd(1) * 256)
  74.     Picture1(i).Visible = -1
  75.     Next i
  76.  
  77. i = 0
  78.     Open "ICONS.DAT" For Input As #1 ' Open file for input.
  79.     Indx% = 0
  80.     Do While Not EOF(1) And Indx% <= 500    ' Check for end of file.
  81.     Input #1, b$(Indx%)  ' Read data.
  82.     Indx% = Indx% + 1   ' Increment index.
  83.     Loop
  84.  
  85.     Close #1    ' Close data file.
  86.     ActualIcons = Indx%
  87.     Indx% = 0
  88.     Open "WAVS.DAT" For Input As #1 ' Open file for input.
  89.     Do While Not EOF(1) And Indx% <= 114    ' Check for end of file.
  90.     Input #1, a$(Indx%)  ' Read data.
  91.     Indx% = Indx% + 1   ' Increment index.
  92.     Loop
  93.  
  94.     Close #1    ' Close data file.
  95.     ActualWavs = Indx%
  96.  
  97. Rem if we have less than 114, use what we have to
  98. Rem fill the remaining entries.
  99.  
  100.     If ActualWavs < 114 Then
  101.     For i = ActualWavs To 113
  102.     a$(i) = a$(i Mod ActualWavs)
  103.     Next i
  104.     End If
  105.  
  106. End Sub
  107.  
  108. Sub Picture1_Click (index As Integer)
  109. Rem make each series of icons different (yeah, there are better ways to do this...)
  110. For i = 1 To index
  111. j = Rnd(1)
  112. Next i
  113. j = Int(Rnd(1) * ActualIcons)
  114. s$ = b$(j)
  115. Rem drop the .ICO
  116. s$ = Left$(b$(j), Len(b$(j)) - 4)
  117. Rem drop the path, if there is one
  118. 500 For i = 1 To Len(s$)
  119.     If Mid$(s$, i, 1) = "\" Then
  120.     s$ = Mid$(s$, i + 1)
  121.     GoTo 500
  122.     End If
  123. Next i
  124. Picture1(index).Picture = LoadPicture(b$(j))
  125. Name2.Text = s$
  126. SoundName$ = a$(index)
  127. wFlag% = SND_ASYNC Or SND_NODEFAULT
  128. Rem drop the .WAV
  129. s$ = Left$(a$(index), Len(a$(index)) - 4)
  130. Rem drop the path, if there is one
  131. 50 For i = 1 To Len(s$)
  132.     If Mid$(s$, i, 1) = "\" Then
  133.     s$ = Mid$(s$, i + 1)
  134.     GoTo 50
  135.     End If
  136. Next i
  137. Name1.Text = s$
  138. x% = sndPlaySound(SoundName$, wFlag%)
  139. End Sub
  140.  
  141.